"""Site URLs."""

import os
from django.conf.urls.defaults import *
from django.conf import settings

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('hcp.views',

    (r'^$', 'index'),

    # Example:
    # (r'^hcp/', include('hcp.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # (r'^admin/(.*)', admin.site.root),
)

urlpatterns += patterns('hcp.auth.views',
    url(r'^accounts/login/$', 'login',
        name='hcp-login'),
    url(r'^accounts/logout/$', 'logout',
        name='hcp-logout'),
)

urlpatterns += patterns('hcp.views.users',
    url(r'^users/$',
        'index',
        name='hcp-users'),
    url(r'^users/list/$',
        'user_list',
        name='hcp-json-users'),
    url(r'^users/new/$',
        'new',
        name='hcp-users-new'),
    url(r'^users/edit/(?P<dn>[^/]+)/$',
        'edit',
        name='hcp-users-edit'),
    url(r'^users/delete/(?P<dn>[^/]+)/$',
        'remove',
        name='hcp-users-delete'),
)

urlpatterns += patterns('hcp.views.domains',
    url(r'^domains/$',
        'index',
        name='hcp-domains'),
    url(r'^domains/list/$',
        'domain_list',
        name='hcp-json-domains'),
    url(r'^domains/new/$',
        'new',
        name='hcp-domains-new'),
    url(r'^domains/edit/(?P<dn>[^/]+)/$',
        'edit',
        name='hcp-domains-edit'),
    url(r'^domains/delete/(?P<dn>[^/]+)/$',
        'remove',
        name='hcp-domains-delete'),
)

urlpatterns += patterns('hcp.views.hosts',
    url(r'^hosts/$',
        'index',
        name='hcp-hosts'),
    url(r'^hosts/list/$',
        'host_list',
        name='hcp-json-hosts'),
    url(r'^hosts/new/$',
        'new',
        name='hcp-hosts-new'),
    url(r'^hosts/edit/(?P<dn>[^/]+)/$',
        'edit',
        name='hcp-hosts-edit'),
    url(r'^hosts/delete/(?P<dn>[^/]+)/$',
        'remove',
        name='hcp-hosts-delete'),
)

urlpatterns += patterns('hcp.views.mail_aliases',
    url(r'^mail_aliases/$',
        'index',
        name='hcp-mail-aliases'),
    url(r'^mail_aliases/list/$',
        'mail_alias_list',
        name='hcp-json-mail-aliases'),
    url(r'^mail_aliases/new/$',
        'new',
        name='hcp-mail-aliases-new'),
    url(r'^mail_aliases/edit/(?P<dn>[^/]+)/$',
        'edit',
        name='hcp-mail-aliases-edit'),
    url(r'^mail_aliases/delete/(?P<dn>[^/]+)/$',
        'remove',
        name='hcp-mail-aliases-delete'),
)

urlpatterns += patterns('hcp.views.groups',
    url(r'^groups/$',
        'index',
        name='hcp-groups'),
    url(r'^groups/list/$',
        'group_list',
        name='hcp-json-groups'),
    url(r'^groups/new/$',
        'new',
        name='hcp-groups-new'),
    url(r'^groups/edit/(?P<dn>[^/]+)/$',
        'edit',
        name='hcp-groups-edit'),
    url(r'^groups/delete/(?P<dn>[^/]+)/$',
        'remove',
        name='hcp-groups-delete'),
)

urlpatterns += patterns('hcp.views.activity',
    url(r'^activity/$',
        'index',
        name='hcp-activity'),
)

if settings.DEBUG:
    def htdocs_path(d):
        return os.path.join(settings.HTDOCS_ROOT, d)

    urlpatterns += patterns('',
        (r'^css/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': htdocs_path('css'),
            }),
        (r'^images/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': htdocs_path('images'),
            }),
        (r'^js/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': htdocs_path('js'),
            }),
    )
